﻿@model LuxDiner.Model.Products.ProductCategoryModel

<div class="GeneralEdit" id="fmCategory">
    <ul>
        <li>
            <label for="txtCategoryName">分类名称：</label>
            <input type="text" class="k-textbox" id="txtCategoryName" name="categoryName" value="@Model.CategoryName" maxlength="50" pattern=".{2,}" required validationMessage="请输入分类名称" />
            <span class="k-invalid-msg" data-for="categoryName"></span>
        </li>
        <li class="editButtons">
            <button id="btnSaveCategory" class="k-button"><span class="k-icon k-i-tick"></span><span>确认提交</span></button>
            &nbsp;&nbsp;
            <button class="k-button" onclick="CancelGeneralEdit();"><span class="k-icon k-i-cancel"></span><span>&nbsp;返&nbsp;回</span></button>
        </li>
    </ul>
</div>

<script class="save_category">
    $(function () {
        var validator = $("#fmCategory").kendoValidator().data("kendoValidator");
        $("#btnSaveCategory").click(function (e) {
            if (validator.validate()) {
                var values = {
                    categoryID: "@Model.ID",
                    categoryName: $("#txtCategoryName").val(),
                };

                Whale.Remote.Operation({
                    url: "/Products/Category/SaveCategory",
                    parameters: values,
                    success: function (result) {
                        wndGeneralEdit.close();
                        if ($("#grid_category").length > 0)
                            $("#grid_category").data("kendoGrid").dataSource.read();
                    },
                    error: function (msg) {
                        wndGeneralInformation.content(msg).open();
                    }
                });
            }
            return false;
        });
    });
</script>